import { createRouter, createWebHashHistory } from "vue-router";
import Keywords from "@/views/Keywords.vue";

//路由配置
const router = createRouter({
  history: createWebHashHistory(),
  //路由表
  routes: [
    //访问首页的时候，直接重定向跳转到/login，而不去访问home界面
    { path: "/", redirect: "/login" },
    {
      path: "/home",
      name: "home",
      //动态导入懒加载路由组件
      component: () => {
        return import("@/views/home/Home.vue");
      },
      meta: {
        title: "首页",
      },
    },
    {
      path: "/keywords",
      component: Keywords,
      name: "keywords",
      meta: {
        title: "关键字信息",
        desc: "用于展示关键字列表供查阅，可以修改关键字别名",
      },
    },
    {
      path: "/modules",
      component: () => import("@/views/module/Module.vue"),
      name: "module",
      children: [
        {
          path: "case/:moduleId",
          component: () => import("@/views/case/Case.vue"),
          name: "caseInModule",
          // props: true,
          meta: {
            title: "模块管理",
            desc: "对可复用的模块进行管理，右侧用例编辑可以通过拖拽调整用例顺序",
          },
        },
      ],
    },

    {
      path: "/projects",
      component: () => import("@/views/project/Project.vue"),
      name: "project",
      children: [
        {
          path: ":projectId",
          components: {
            module: () => import("@/views/project/ModuleInProject.vue"),
            variable: () => import("@/views/project/VariablesInProject.vue"),
          },
          name: "infoOfProject",
          props: true,
          meta: {
            title: "项目管理",
            desc: "管理自动化项目，能够对模块进行拖拽编辑，以及对项目中使用的变量进行管理，并且可以跳转到运行和报告界面",
          },
        },
      ],
    },

    {
      path: "/run",
      component: () => import("@/views/Run.vue"),
      name: "run",
      meta: {
        title: "运行界面",
        desc: "可以选中项目完成运行，并且展示运行中的日志信息",
      },
    },
    {
      path: "/result",
      component: () => import("@/views/result/Result.vue"),
      name: "result",
      meta: {
        title: "报告展示",
        desc: "展示项目运行的报告结果",
      },
      children: [
        {
          path: ":projectId",
          component: () => import("@/views/result/ResultOfProject.vue"),
          name: "resultOfProject",
          meta: {
            title: "报告展示",
            desc: "展示项目运行的报告结果",
          },
        },
      ],
    },
    {
      path: "/report/:resultId",
      component: () => import("@/views/report/SunnyReport.vue"),
      name: "report",
      meta: {
        title: "报告详情",
        desc: "展示单次项目运行的详细结果",
      },
    },
    {
      path: "/notice",
      component: () => import("@/views/notice/Notice.vue"),
      name: "notice",
      meta: {
        title: "通知消息",
        desc: "显示各个操作处理之后的通知消息",
      },
    },
    {
      path: "/mail",
      component: () => import("@/views/mail/Mail.vue"),
      name: "mail",
      meta: {
        title: "邮件发送",
        desc: "配置发送邮件的配置信息，并选择要发送的结果完成邮件通知",
      },
    },
    {
      path: "/quartzTask",
      component: () => import("@/views/quartzTask/quartzTask.vue"),
      name: "quartzTask",
      meta: {
        title: "定时任务",
        desc: "配置定时任务设置项目的定时运行，请使用cron表达式完成设置",
      },
    },
    {
      path: "/user",
      component: () => import("@/views/user/User.vue"),
      name: "user",
      meta: {
        title: "个人信息",
        desc: "个人信息修改界面，可以单击头像进行上传，以及修改密码",
      },
    },
    {
      path: "/login",
      component: () => import("@/views/user/Login.vue"),
      name: "login",
    },
    {
      path: "/register",
      component: () => import("@/views/user/Register.vue"),
      name: "register",
    },
  ],
});

export default router;
